﻿using Butcher.winform.Dto;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using System.Windows.Forms;
using Traceability.Commont.DTOs.BatchManagementDTOs;

namespace Butcher.winform.EnterpriseForms
{
    public partial class TareSetList : Form
    {
        public TareSetList()
        {
            InitializeComponent();
            getList();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

        public void getList()
        {
            TareSetListSelectDTO tareSetListSelectDTO = new TareSetListSelectDTO();
            tareSetListSelectDTO.PageIndex = 1;
            tareSetListSelectDTO.PageSize = 10;
            tareSetListSelectDTO.ShoppingDesignationid = -1;
            tareSetListSelectDTO.Stact = 0;
            string url = @"http://localhost:5229/api/Batch/SelectTareList";
            HttpClient client = new HttpClient();
            var content = new StringContent(JsonSerializer.Serialize<TareSetListSelectDTO>(tareSetListSelectDTO));
            content.Headers.Remove("Content-Type");
            content.Headers.Add("Content-Type", "application/json");
            string result = client.PostAsync(url, content).Result.Content.ReadAsStringAsync().Result;
            JObject info = JObject.Parse(result);
            var saaa = result;
            var aaa = info["lists"].Value<JArray>();
            List<TareListDTO> enterprises = aaa.ToObject<List<TareListDTO>>();
            dataGridView1.DataSource = enterprises;
        }
    }
}
